{% extends 'back_stage/back_base.html' %}

{% block title %}
<title>后台管理</title>
{% endblock %}

{% block main-content %}
    <table class="table table-bordered table-hover table-striped">
                <thead>
                <tr>
                    <th>标题</th>
                    <th>发布日期</th>
                    <th>评论数</th>
                    <th>点赞数</th>
                    <th>操作</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                    {% for article in current_page %}
                        <tr>
                            <td>
                                <a href="/{{ request.user.username }}/articles/{{ article.nid }}/">{{ article.title }}</a>
                            </td>
{#                        日期要加过滤，格式化#}
                            <td>{{ article.create_time|date:'Y-m-d H:i' }}</td>
                            <td>{{ article.comment_count }}</td>
                            <td>{{ article.up_count }}</td>
                            <td>
                                <a id="{{ article.pk }}" class="delete-button" data-toggle="modal" data-target="#myModal" href="">删除</a>
                            </td>
                            <td>
                                <a href="/article/{{ article.pk }}/editor">编辑</a>
                            </td>
                        </tr>
                    {% endfor book_list%}
                </tbody>
            </table>
{% endblock %}

{#分页器#}
{% block paginator %}
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-6 col-md-offset-2">
                    <nav aria-label="Page navigation" class="home_site_paginator" style="display: none">
        <ul class="pagination">
{#              上一页#}
        {% if current_page.has_previous %}
            <li>
                <a class="ends" href="?page={{ current_page.previous_page_number }}" aria-label="Previous">
                    <span aria-hidden="true">上一页</span>
                </a>
            </li>
        {% else %}
{#            如果没有上一页了，就把标签禁止，且没有连接#}
            <li class="disabled">
                <a class="ends" href="" aria-label="Previous">
                    <span aria-hidden="true">上一页</span>
                </a>
            </li>
        {% endif %}
{#              中间的页码#}
            {% for page in page_range %}
{#                如果循环的页码等于当前的页码，就添加active#}
                {% if current_page_num == page%}
                    <li class="active"><a href="?page={{ page }}">{{ page }}</a></li>
                {% else %}
                    <li><a href="?page={{ page }}">{{ page }}</a></li>
                {% endif %}
            {% endfor %}

{#              下一页#}
        {% if current_page.has_next %}
            <li>
                <a class="ends" href="?page={{ current_page.next_page_number }}" aria-label="Next">
                    <span aria-hidden="true">下一页</span>
                </a>
            </li>
        {% else %}
{#            如果没有下一页了，就把标签禁止，且没有连接#}
            <li class="disabled">
                <a class="ends" href="" aria-label="Next">
                    <span aria-hidden="true">下一页</span>
                </a>
            </li>
        {% endif %}

  </ul>
</nav>
            </div>
        </div>
    </div>
{% endblock %}